package com.feonix.common.util;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
/**
 *  提供系统缓存资源
 * <p>Title: CacheUtil</p>
 * @version 1.0
 */
public class CacheUtil {
	private static Logger logger = Logger.getLogger(CacheUtil.class);



	private static ThreadPoolExecutor pool;
    private static int threadPoolSize;

	public static void setThreadPoolSize(int threadPoolSize) {
		CacheUtil.threadPoolSize = threadPoolSize;
	}
    public void init()
    {
      pool = new ThreadPoolExecutor(threadPoolSize, threadPoolSize * 2, 60L, TimeUnit.SECONDS, 
        new LinkedBlockingQueue<Runnable>());
    }
    
    public static ThreadPoolExecutor getPool() {
		return pool;
	}
    public void destroy() {
        logger.info("系统停止开始。。。");
   
        if (pool != null) {
          pool.shutdown();
          logger.info("系统线程池停止完成！");
        }
        
      }
}
